package com.xuhai.blog.api;

import com.xuhai.blog.admin.service.TimelineService;
import com.xuhai.blog.common.util.ResultJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author PangJunjie
 * @Date 2022/2/19/019
 */
@RestController
@RequestMapping("/api")
public class TimelineController {
    @Autowired
    private TimelineService timelineService;

    @GetMapping("/timeline")
    public ResultJson getTimeline(){
        return ResultJson.ok().data(timelineService.getTimeLine());
    }

    @GetMapping("/timeline/{year}")
    public ResultJson getArticleListByYear(@PathVariable String year){
        return ResultJson.ok().data(timelineService.getArticleListByYear(year));
    }
}
